<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="style.css" type="text/css"/>
<title>Oaxaca: Console</title>
</head>

<body>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="oaxaca.js"></script>

<h1 class="console">Oaxaca: Console</h1>

<div class="panel detector-panel wfs-detector-panel">
<h2 class="panel">WFS</h2>
<div class="detector-image"><img src="detector-latest-image.cgi?detector=wfs" alt="WFS" id="wfs-latest-image"/></div>
<div class="summary" id="wfs-summary"></div>

<table>
<tr>
<td>
<form id="wfs-idle">
<input type="submit" value="Idle" class="submit"/>
</form>
</td>
<td>
<form id="wfs-details">
<input type="submit" value="Details" class="submit"/>
</form>
</td>
</tr>
</table>

<table>
<tr>
<td>
<form id="wfs-configure">
<input type="submit" value="Configure Detector" class="submit"/>
</form>
</td>
<td>
<form>
<select id="wfs-configure-arg">
<option value="full-frame-1">Full-Frame 1 Hz</option>
<option value="full-frame-2">Full-Frame 2 Hz</option>
<option value="full-frame-4">Full-Frame 4 Hz</option>
<option value="full-frame-8">Full-Frame 8 Hz</option>
<option value="full-frame-16">Full-Frame 16 Hz</option>
<option value="half-frame-1">Half-Frame 1 Hz</option>
<option value="half-frame-2">Half-Frame 2 Hz</option>
<option value="half-frame-4">Half-Frame 4 Hz</option>
<option value="half-frame-8">Half-Frame 8 Hz</option>
<option value="half-frame-16">Half-Frame 16 Hz</option>
<option value="half-frame-32">Half-Frame 32 Hz</option>
<option value="half-frame-64">Half-Frame 64 Hz</option>
<option value="sub-frame-2">Sub-Frame 2 Hz</option>
<option value="sub-frame-4">Sub-Frame 4 Hz</option>
<option value="sub-frame-8">Sub-Frame 8 Hz</option>
<option value="sub-frame-16">Sub-Frame 16 Hz</option>
<option value="sub-frame-32">Sub-Frame 32 Hz</option>
<option value="sub-frame-40">Sub-Frame 40 Hz</option>
<option value="sub-frame-50">Sub-Frame 50 Hz</option>
<option value="sub-frame-64">Sub-Frame 64 Hz</option>
<option value="sub-frame-80">Sub-Frame 80 Hz</option>
<option value="sub-frame-100">Sub-Frame 100 Hz</option>
<option value="sub-frame-125">Sub-Frame 125 Hz</option>
<option value="sub-frame-160">Sub-Frame 160 Hz</option>
<option value="sub-frame-200">Sub-Frame 200 Hz</option>
<option value="sub-frame-250">Sub-Frame 250 Hz</option>
<option value="sub-frame-320">Sub-Frame 320 Hz</option>
<option value="sub-frame-400">Sub-Frame 400 Hz</option>
<option value="sub-frame-500">Sub-Frame 500 Hz</option>
</select>
</form>
</td>
</tr>
</table>

<form id="wfs-expose">
<table>
<tr>
<td>
<input type="submit" value="Expose" class="submit"/>
</td>
<td>
<input type="text" id="wfs-expose-args" class="text"/>
</td>
</tr>
</table>
</form>

<form id="wfs-dark">
<table>
<tr>
<td>
<input type="submit" value="Dark" class="submit"/>
</td>
<td>
<input type="text" id="wfs-dark-args" class="text"/>
</td>
</tr>
</table>
</form>

<form id="wfs-correct">
<table>
<tr>
<td>
<input type="submit" value="Correct" class="submit"/>
</td>
<td>
<input type="text" id="wfs-correct-args" class="text"/>
</td>
</tr>
</table>
</form>

<form id="wfs-set-mode-gains">
<table>
<tr>
<td>
<input type="submit" value="Set Mode Gains" class="submit"/>
</td>
<td>
<input type="text" id="wfs-set-mode-gains-args" class="text"/>
</td>
</tr>
</table>
</form>

</div>

</div><div class="panel detector-panel instrument-detector-panel">
<h2 class="panel">Instrument</h2>
<div class="detector-image"><img src="detector-latest-image.cgi?detector=instrument" alt="Instrument" id="instrument-latest-image"/></div>
<div class="summary" id="instrument-summary"></div>

<table>
<tr>
<td>
<form id="instrument-idle">
<input type="submit" value="Idle" class="submit"/>
</form>
</td>
<td>
<form id="instrument-details">
<input type="submit" value="Details" class="submit"/>
</form>
</td>
</tr>
</table>

<table>
<tr>
<td>
<form id="instrument-configure">
<input type="submit" value="Configure Detector" class="submit"/>
</form>
</td>
<td>
<form>
<select id="instrument-configure-arg">
<option value="full-frame-1">Full-Frame 1 Hz</option>
<option value="full-frame-2">Full-Frame 2 Hz</option>
<option value="full-frame-4">Full-Frame 4 Hz</option>
<option value="full-frame-8">Full-Frame 8 Hz</option>
<option value="full-frame-16">Full-Frame 16 Hz</option>
<option value="half-frame-1">Half-Frame 1 Hz</option>
<option value="half-frame-2">Half-Frame 2 Hz</option>
<option value="half-frame-4">Half-Frame 4 Hz</option>
<option value="half-frame-8">Half-Frame 8 Hz</option>
<option value="half-frame-16">Half-Frame 16 Hz</option>
<option value="half-frame-32">Half-Frame 32 Hz</option>
<option value="half-frame-64">Half-Frame 64 Hz</option>
<option value="sub-frame-2">Sub-Frame 2 Hz</option>
<option value="sub-frame-4">Sub-Frame 4 Hz</option>
<option value="sub-frame-8">Sub-Frame 8 Hz</option>
<option value="sub-frame-16">Sub-Frame 16 Hz</option>
<option value="sub-frame-32">Sub-Frame 32 Hz</option>
<option value="sub-frame-40">Sub-Frame 40 Hz</option>
<option value="sub-frame-50">Sub-Frame 50 Hz</option>
<option value="sub-frame-64">Sub-Frame 64 Hz</option>
<option value="sub-frame-80">Sub-Frame 80 Hz</option>
<option value="sub-frame-100">Sub-Frame 100 Hz</option>
<option value="sub-frame-125">Sub-Frame 125 Hz</option>
<option value="sub-frame-160">Sub-Frame 160 Hz</option>
<option value="sub-frame-200">Sub-Frame 200 Hz</option>
<option value="sub-frame-250">Sub-Frame 250 Hz</option>
<option value="sub-frame-320">Sub-Frame 320 Hz</option>
<option value="sub-frame-400">Sub-Frame 400 Hz</option>
<option value="sub-frame-500">Sub-Frame 500 Hz</option>
</select>
</form>
</td>
</tr>
</table>

<form id="instrument-expose">
<table>
<tr>
<td>
<input type="submit" value="Expose" class="submit"/>
</td>
<td>
<input type="text" id="instrument-expose-args" class="text"/>
</td>
</tr>
</table>
</form>

<form id="instrument-dark">
<table>
<tr>
<td>
<input type="submit" value="Dark" class="submit"/>
</td>
<td>
<input type="text" id="instrument-dark-args" class="text"/>
</td>
</tr>
</table>
</form>

<form id="instrument-correct">
<table>
<tr>
<td>
<input type="submit" value="Correct" class="submit"/>
</td>
<td>
<input type="text" id="instrument-correct-args" class="text"/>
</td>
</tr>
</table>
</form>

<form id="instrument-set-mode-gains">
<table>
<tr>
<td>
<input type="submit" value="Set Mode Gains" class="submit"/>
</td>
<td>
<input type="text" id="instrument-set-mode-gains-args" class="text"/>
</td>
</tr>
</table>
</form>

</div>

<div class="panel detector-panel finder-detector-panel">
<h2 class="panel">Finder</h2>
<div class="detector-image"><img src="detector-latest-image.cgi?detector=finder" alt="Finder" id="finder-latest-image"/></div>
<div class="summary" id="finder-summary"></div>

<table>
<tr>
<td>
<form id="finder-idle">
<input type="submit" value="Idle" class="submit"/>
</form>
</td>
<td>
<form id="finder-details">
<input type="submit" value="Details" class="submit"/>
</form>
</td>
</tr>
</table>

<table>
<tr>
<td>
<form id="finder-configure">
<input type="submit" value="Configure Detector" class="submit"/>
</form>
</td>
<td>
<form>
<select id="finder-configure-arg">
<option value="full-frame-1">Full-Frame 1 Hz</option>
<option value="full-frame-2">Full-Frame 2 Hz</option>
<option value="full-frame-4">Full-Frame 4 Hz</option>
<option value="full-frame-8">Full-Frame 8 Hz</option>
<option value="full-frame-16">Full-Frame 16 Hz</option>
<option value="half-frame-1">Half-Frame 1 Hz</option>
<option value="half-frame-2">Half-Frame 2 Hz</option>
<option value="half-frame-4">Half-Frame 4 Hz</option>
<option value="half-frame-8">Half-Frame 8 Hz</option>
<option value="half-frame-16">Half-Frame 16 Hz</option>
<option value="half-frame-32">Half-Frame 32 Hz</option>
<option value="half-frame-64">Half-Frame 64 Hz</option>
</select>
</form>
</td>
</tr>
</table>

<form id="finder-expose">
<table>
<tr>
<td>
<input type="submit" value="Expose" class="submit"/>
</td>
<td>
<input type="text" id="finder-expose-args" class="text"/>
</td>
</tr>
</table>
</form>

<form id="finder-dark">
<table>
<tr>
<td>
<input type="submit" value="Dark" class="submit"/>
</td>
<td>
<input type="text" id="finder-dark-args" class="text"/>
</td>
</tr>
</table>
</form>

</div>

<script language="javascript">
$(function () {
  refreshhtml("wfs-summary", "scm", "(display-status 'wfs-summary)");
  refreshhtml("instrument-summary", "scm", "(display-status 'instrument-summary)");
  refreshhtml("finder-summary", "scm", "(display-status 'finder-summary)");
  refreshhtml("housekeeping-summary", "scm", "(display-status 'housekeeping-summary)");
  refreshhtml("lamp-summary", "scm", "(display-status 'lamp-summary)");
  refreshhtml("wfc-summary", "scm", "(display-status 'wfc-summary)");
  refreshimage("wfs-latest-image", "detector-latest-image.cgi?detector=wfs");
  refreshimage("instrument-latest-image", "detector-latest-image.cgi?detector=instrument");
  refreshimage("finder-latest-image", "detector-latest-image.cgi?detector=finder");
});
</script>

<div class="panel pop-up-panel" id="pop-up-panel">
<h2 class="panel" id="pop-up-panel-heading">Foo</h2>
<div id="pop-up-panel-contents">
</div>
<form id="cancel-pop-up">
<input type="submit" value="Cancel"/>
</form>
</div>

<div class="panel housekeeping-panel">
<h2 class="panel">Housekeeping</h2>
<div class="summary" id="housekeeping-summary"></div>
<table>
<tr>
<td>
<form id="reboot">
<input type="submit" value="Reboot" class="submit"/>
</form>
</td>
<td>
<form id="restart">
<input type="submit" value="Restart" class="submit"/>
</form>
</td>
</tr>
</table>
</div>

<div class="panel wfc-panel">
<h2 class="panel">WFC</h2>
<div class="summary" id="wfc-summary"></div>
<table>
<tr>
<td>
<form id="wfc-zero">
<input type="submit" value="Zero" class="submit"/>
</form>
</td>
<td>
<form id="wfc-flatten">
<input type="submit" value="Flatten" class="submit"/>
</form>
</td>
</tr>
</table>
</div>

<div class="panel lamp-panel">
<h2 class="panel">Lamp</h2>
<div class="summary" id="lamp-summary"></div>
<table>
<tr>
<td>
<form id="lamp-on">
<input type="submit" value="On" class="submit"/>
</form>
</td>
<td>
<form id="lamp-off">
<input type="submit" value="Off" class="submit"/>
</form>
</td>
</tr>
</table>
</div>

<div class="panel telescope-panel">
<h2 class="panel">Telescope</h2>

<p></p>

<table>

<tr>
<td>
<form id="telescope-offset-ne">
<input type="submit" value="NE" class="submit offset"/>
</form>
</td>
<td>
<form id="telescope-offset-n">
<input type="submit" value="N" class="submit offset"/>
</form>
</td>
<td>
<form id="telescope-offset-nw">
<input type="submit" value="NW" class="submit offset"/>
</form>
</td>
</tr>

<tr>
<td>
<form id="telescope-offset-e">
<input type="submit" value="E" class="submit offset"/>
</form>
</td>
<td>
</td>
<td>
<form id="telescope-offset-w">
<input type="submit" value="W" class="submit offset"/>
</form>
</td>
</tr>

<tr>
<td>
<form id="telescope-offset-se">
<input type="submit" value="SE" class="submit offset"/>
</form>
</td>
<td>
<form id="telescope-offset-s">
<input type="submit" value="S" class="submit offset"/>
</form>
</td>
<td>
<form id="telescope-offset-sw">
<input type="submit" value="SW" class="submit offset"/>
</form>
</td>
</tr>

</table>

<p></p>

<table>

<tr>
<td>
Offset Size
</td>
<td>
<input type="text" id="offset-args" class="text"/>
</td>
</tr>

<tr>
<td>
<form id="telescope-offset-1">
<input type="submit" value="1" class="submit"/>
</form>
</td>
<td>
<form id="telescope-offset-3">
<input type="submit" value="3" class="submit"/>
</form>
</td>
</tr>

<tr>
<td>
<form id="telescope-offset-10">
<input type="submit" value="10" class="submit"/>
</form>
</td>
<td>
<form id="telescope-offset-30">
<input type="submit" value="30" class="submit"/>
</form>
</td>
</tr>

</table>

<p></p>

<table>

<tr>
<td>
<form id="telescope-focus-up">
<input type="submit" value="Focus Up" class="submit"/>
</form>
</td>
<td>
<form id="telescope-focus-down">
<input type="submit" value="Focus Down" class="submit"/>
</form>
</td>
</tr>

</table>

</div>

<script language="javascript">
$(function () {

  $("form#reboot").submit(function () {
    return sh("sudo /sbin/reboot", "reboot oaxaca-pc");
  });
  $("form#restart").submit(function () {
    return sh("sudo $(which oaxaca-start)", "restart the control system");
  });
  $("form#wfs-expose").submit(function () {
    return scm("(wfs-expose! " + $("input#wfs-expose-args").val() + ")", false);
  });
  $("form#wfs-dark").submit(function () {
    return scm("(wfs-dark! " + $("input#wfs-dark-args").val() + ")", false);
  });
  $("form#wfs-correct").submit(function () {
    return scm("(wfs-correct! " + $("input#wfs-correct-args").val() + ")", false);
  });
  $("form#wfs-set-mode-gains").submit(function () {
    return scm("(wfs-set-g-vector! #(" + $("input#wfs-set-mode-gains-args").val() + "))", false);
  });
  $("form#wfs-idle").submit(function () {
    return scm("(wfs-idle!)", false);
  });
  $("form#wfs-configure").submit(function () {
    return scm("(wfs-configure! '" + $("select#wfs-configure-arg").val() + ")", false);
  });
  $("form#wfs-details").submit(function () {
    $("h2#pop-up-panel-heading").html("WFS Details");
    refreshpopup("pop-up-panel-contents", "scm", "(display-status 'wfs-details)");
    $("div#pop-up-panel").show();
    return false;
  });
  $("form#instrument-expose").submit(function () {
    return scm("(instrument-expose! " + $("input#instrument-expose-args").val() + ")", false);
  });
  $("form#instrument-dark").submit(function () {
    return scm("(instrument-dark! " + $("input#instrument-dark-args").val() + ")", false);
  });
  $("form#instrument-correct").submit(function () {
    return scm("(instrument-correct! " + $("input#instrument-correct-args").val() + ")", false);
  });
  $("form#instrument-set-mode-gains").submit(function () {
    return scm("(instrument-set-g-vector! #(" + $("input#instrument-set-mode-gains-args").val() + "))", false);
  });
  $("form#instrument-idle").submit(function () {
    return scm("(instrument-idle!)", false);
  });
  $("form#instrument-configure").submit(function () {
    return scm("(instrument-configure! '" + $("select#instrument-configure-arg").val() + ")", false);
  });
  $("form#instrument-details").submit(function () {
    $("h2#pop-up-panel-heading").html("instrument Details");
    refreshpopup("pop-up-panel-contents", "scm", "(display-status 'instrument-details)");
    $("div#pop-up-panel").show();
    return false;
  });
  $("form#finder-expose").submit(function () {
    return scm("(finder-expose! " + $("input#finder-expose-args").val() + ")", false);
  });
  $("form#finder-dark").submit(function () {
    return scm("(finder-dark! " + $("input#finder-dark-args").val() + ")", false);
  });
  $("form#finder-idle").submit(function () {
    return scm("(finder-idle!)", false);
  });
  $("form#finder-configure").submit(function () {
    return scm("(finder-configure! '" + $("select#finder-configure-arg").val() + ")", false);
  });
  $("form#finder-details").submit(function () {
    $("h2#pop-up-panel-heading").html("finder Details");
    refreshpopup("pop-up-panel-contents", "scm", "(display-status 'finder-details)");
    $("div#pop-up-panel").show();
    return false;
  });
  $("form#cancel-pop-up").submit(function () {
    stoprefreshingpopup();
    $("div#pop-up-panel").hide();
    return false;
  });
  $("form#lamp-on").submit(function () {
    return scm("(lamp-set-state! #t)", false);
  });
  $("form#lamp-off").submit(function () {
    return scm("(lamp-set-state! #f)", false);
  });
  $("form#wfc-zero").submit(function () {
    return scm("(wfc-zero!)", false);
  });
  $("form#wfc-flatten").submit(function () {
    return scm("(wfc-flatten!)", false);
  });

  $("form#telescope-offset-n").submit(function () {
    offset = parseFloat($("input#offset-args").val());
    return scm("(telescope-offset! +0 " + (+offset) + ")", false);
  });
  $("form#telescope-offset-e").submit(function () {
    offset = parseFloat($("input#offset-args").val());
    return scm("(telescope-offset! " + (+offset) + " +0)", false);
  });
  $("form#telescope-offset-s").submit(function () {
    offset = parseFloat($("input#offset-args").val());
    return scm("(telescope-offset! +0 " + (-offset) + ")", false);
  });
  $("form#telescope-offset-w").submit(function () {
    offset = parseFloat($("input#offset-args").val());
    return scm("(telescope-offset! " + (-offset) + " +0)", false);
  });
  $("form#telescope-offset-ne").submit(function () {
    offset = parseFloat($("input#offset-args").val()) / Math.sqrt(2);
    return scm("(telescope-offset! " + (+offset) + " " + (+offset) + ")", false);
  });
  $("form#telescope-offset-nw").submit(function () {
    offset = parseFloat($("input#offset-args").val()) / Math.sqrt(2);
    return scm("(telescope-offset! " + (-offset) + " " + (+offset) + ")", false);
  });
  $("form#telescope-offset-se").submit(function () {
    offset = parseFloat($("input#offset-args").val()) / Math.sqrt(2);
    return scm("(telescope-offset! " + (+offset) + " " + (-offset) + ")", false);
  });
  $("form#telescope-offset-sw").submit(function () {
    offset = parseFloat($("input#offset-args").val()) / Math.sqrt(2);
    return scm("(telescope-offset! " + (-offset) + " " + (-offset) + ")", false);
  });

  $("input#offset-args").val("3");

  $("form#telescope-offset-1").submit(function () {
    $("input#offset-args").val("1");
    return false;
  });
  $("form#telescope-offset-3").submit(function () {
    $("input#offset-args").val("3");
    return false;
  });
  $("form#telescope-offset-10").submit(function () {
    $("input#offset-args").val("10");
    return false;
  });
  $("form#telescope-offset-30").submit(function () {
    $("input#offset-args").val("30");
    return false;
  });
  
  $("form#telescope-focus-up").submit(function () {
    return scm("(telescope-focus! +1)", false);
  });
  $("form#telescope-focus-down").submit(function () {
    return scm("(telescope-focus! -1)", false);
  });

});
</script>

<div class="panel log-panel">
<h2>Log</h2>
<div class="log" id="log"></div>
</div>

<script language="javascript">
$(function () {
  refreshhtml("log", "log");
});
</script>

</body>

</html>
